Skip to content

Port sedutil to FreeBSD and add many new features.#87

Open
amotin wants to merge 51 commits intoDrive-Trust-Alliance:masterfrom
amotin:master
Open

Port sedutil to FreeBSD and add many new features.#87
amotin wants to merge 51 commits intoDrive-Trust-Alliance:masterfrom
amotin:master

Conversation

@amotin
Copy link

@amotin amotin commented Aug 29, 2016

This includes support for ATA and SCSI disks via CAM pass API.
This includes support for NVMe via IOCTL API (not really tested due to lack of hardware).

This includes support for ATA and SCSI disks via CAM pass API.
This includes support for NVMe via IOCTL API (not really tested).
@cristim
Copy link

cristim commented May 21, 2017

I forked the project into a new Github organization, and it's available at https://github.com/sedutil/sedutil

Please join us there and re-submit this PR, we promise to merge it timely after passing the code review.

Later edit: please ignore this, it seems DTA resumed active development so this fork is no longer needed.

@r0m30
Copy link
Contributor

r0m30 commented Jul 21, 2017

Very nicely done. Thanks.
We have two paths forward:

  1. With a signed contributor agreement we can merge this into master.
  2. Without a signed contributor agreement we can create an unsupported FreeBSD branch.

If we go option 1 then I will (try at least) to ensure that the code keeps up with future versions. I'll probably have to test booting to a usb attached device since my MoBo shares PCI lanes for the NVMe and SATA express ports I lost two SATA ports with my recent acquisition of an NVMe drive for testing.

If we go with option 2 then the community will need to maintain compatibility with future releases.

While this has no conflicts, I don't think it will cleanly compile and link with the current code (see DtaDevOS::scanDisk()). This additional static function allows us to work around NVMe drives not being /dev/sd? in Linux.

@r0m30 r0m30 self-requested a review July 21, 2017 00:44
Copy link
Contributor

@r0m30 r0m30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awaiting Contributor agreement.

@r0m30 r0m30 mentioned this pull request Jul 21, 2017
amotin added 19 commits April 6, 2018 16:43
Tested with SATA/Opal2 and SAS/Enterprise disks.
Those features I found implemented on Samsung 970 Pro NVMe.
Previous code was not reporting errors reported by the device.
I do not completely understand how this code supposed to work,
all I see is that it just does not.
For SATA and NVMe devices we know explicitly whether they support
Trusted Computing feature set and Security Send/Receive commands.
This prevents errors from happening and being reported by kernel.
This is just for future reference.
This code handles both ATA and SCSI via CAM interface, and potentially
may handle NVMe.
That parameter is optional even for Enterprise, and we found some
devices failing StartSession when it is specified.
There may be some rough edges, but with this I successfully initialized,
locked, unlocked and reverted Intel Optane 905 SSD, implementing Pyrite 1.0.
There are drives uing both upper and lower case symbols.
@emaste
Copy link

emaste commented Jun 9, 2019

@amotin are you able to sign a contributor agreement for upstreaming?

@amotin
Copy link
Author

amotin commented Jun 9, 2019

Yes, if necessary.

Should be no functional changes.
There are some Toshiba NVMe SSDs that fail attempts to enable PBA
or load it.  Since I don't think why it should be critical for devices
not used for boot, ignore that error.  Same time leave it there just
to keep backward compatibility.
@amotin amotin changed the title Port sedutil to FreeBSD. Port sedutil to FreeBSD and add many new features. Aug 12, 2020
amotin and others added 19 commits August 12, 2020 13:28
It can be pretty long to list all the ranges, and actually looks like
a bug, since Enterprise code always listed only one range there.
When needed --listLockingRanges still can list all of them.
On different Enterprise drives both of them appear to be useful.
These two fields are uint8_t (unsigned char), causing them to be treated
as literal char instead of int values. Need to cast to some int type to fix
that.
Fix verbose (-vvv..) command line arguments.
We've found thet some SAS/SATA interposers report incorrect error
"ILLEGAL REQUEST asc:25,0 (Logical unit not supported)" when device
behind them does not support TCG, that cause FreeBSD CAM to detach
the LUN.  To workaround that check whether SCSI device reports ATA
Information VPD page, and if so, that it reports TCG support there.
It is pretty confusing to see errors if caller is going to handle
them, either with retrial or custom reporting.  Add parameter to
mute the logging and use it in DtaSession::start() when retrying
without SessionTimeout token.
I am not sure how it worked before, may be previous Linux kernels
reported device errors as ioctl errors, but at least now it is no so.
Extend error handling to SCSI, driver and host statuses, that fixes
SAS disks operation, since otherwise due to lack of error handling
for IDENTIFY request they were incorrectly handled as SATA.

While there, alike to FreeBSD add check for TCG bit in ATA IDENTIFY
data to avoid unneeded unsupported commands errors later.
The sedutil scan currently does not display drives other than sdX.
In this commit, we extend the scan to include sdXYZ and, while we're
at it, also add the scan for nvmeXYZ drives.
sedutil uses the serial number to hash the password for NVMe disk types
and the model number for SCSI disk types. Tri-mode NVMe devices are
exposed as SCSI devices, making them incompatible on non-tri-mode HBAs.
This patch automates disk type selection by first checking if the disk
is compatible with the NVMe IOCTL interface using the NVME_IOCTL_ID
command. If it's not, it falls back to SCSI.
@scottcmarks
Copy link
Contributor

Which FreeBSD architecture target? By default I would fall into amd64 or i386 but UTM virtualization on my M1 Mac mini is quite fast for aarch64. The OS factoring in the develop branch is supposed to make adding new OSes reasonable; this would be a good exercise.

@scottcmarks scottcmarks self-assigned this Jun 3, 2025
@emaste
Copy link

emaste commented Jun 4, 2025

FreeBSD's two tier-1 architectures are arm64 and amd64 so the two of those will be the most important to target

@dtasupport
Copy link

dtasupport commented Jun 4, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.